package com.woniuxy.project.campus.canteenOrder.config;

import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitMQConfig {
    @Bean
    public Queue delOrderQueue() {
        return new Queue("wait_delete_key_queue");
    }
    @Bean
    public Queue orderCreateQueue() {
        Map<String, Object> args = new HashMap<>();
        args.put("x-message-ttl",  3 * 60 * 1000);
        //定义该队列中消息的生存时间 单位毫秒 生存时间最终对应业务的延迟执行时间
        args.put("x-dead-letter-exchange", "delay-ex");
        // x-dead-letter-exchange 属性用于声明死信转发到的交换机
        args.put("x-dead-letter-routing-key", "orderAuthDeadLet_exchange");
        // x-dead-letter-routing-key 声明了这些死信在转发时携带的路由键名
        return new Queue("Order_Delete", true, false, false, args);
    }

}
